package com.gmrz.util.db;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

public class DBUtil {

    private static final Logger LOG = LogManager.getLogger(DBUtil.class);
    public static void close(Connection c) {
        try {

            if (c != null)
                c.close();
        } catch (Exception ex) {
            LOG.warn("Could not close connection, " + ex.getMessage());
        }
    }

    public static void close(Statement s) {
        try {
            if (s != null)
                s.close();
        } catch (Exception ex) {
            LOG.warn("Could not close statement, " + ex.getMessage());
        }
    }

    public static void close(ResultSet rs) {
        try {
            if (rs != null)
                rs.close();
        } catch (Exception ex) {
            LOG.warn("Could not close resultset, " + ex.getMessage());
        }
    }

    public static void rollback(Connection c) {
        try {
            if (c != null)
                c.rollback();
        } catch (Exception ex) {
            LOG.warn("Could not rollback, " + ex.getMessage());
        }
    }
}
